package com.leesk.trial.springbootdatastatistics.config;

import com.leesk.trial.springbootdatastatistics.pojo.RegionStats;
import com.leesk.trial.springbootdatastatistics.util.CsvUtil;
import com.leesk.trial.springbootdatastatistics.util.TransferUtil;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: leesk
 * @Description:用于测试    //已改为单元测试完成...
 * 配置类，项目启动时自动加载
 * 即时获取数据
 * @Date: Create in 15:11 2020/11/16
 */
@Configuration
public class CsvConfig{
//    private static final String CoronaVirusDataURL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/11-18-2020.csv";
//    private static List<RegionStats> regionStats =  new ArrayList<>();
//
//    @Override
//    public void afterPropertiesSet() throws Exception {
//
//        InputStream inputStream = CsvUtil.fetchCoronaVirusData(CoronaVirusDataURL);
//        regionStats = CsvUtil.getCoronaVirusData(inputStream);
//    }

    @Bean
    public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        factory.setReadTimeout(5000);//单位为ms
        factory.setConnectTimeout(5000);//单位为ms
        return factory;
    }
}
